package com.cjq.auth.controller;

import com.cjq.auth.service.AuthService;
import com.cjq.common.domain.SysUser;
import com.cjq.common.domain.request.SysUserReq;
import com.cjq.common.domain.response.SysUserRes;
import com.cjq.common.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class AuthController {
    @Autowired
    private AuthService authService;

    /**
     * 账号密码登录
     * @param sysUserReq
     * @return
     */
    @PostMapping("/accountLogin")
    public Result<SysUserRes> accountLogin(@RequestBody SysUserReq sysUserReq){
        return authService.accountLogin(sysUserReq);
    }

    /**
     * 获取用户信息
     * @return
     */
    @GetMapping("/userInfo")
    public Result<SysUser> userInfo(){
        return authService.userInfo();
    }

    /**
     * 退出登录
     * @return
     */
    @PostMapping("/logout")
    public Result logout(){
        return authService.logout();
    }

}
